﻿#include "FITKAbaqusHDF5AdaptorCase.h"
#include "FITK_Kernel/FITKCore/FITKEnumTransformer.hpp"
#include "FITKAbaqusHDF5Reader.h"
#include "FITKAbaqusHDF5Writer.h"
#include "FITKAbaqusHDF5AdaptorPart.h"
#include "FITKAbaqusHDF5AdaptorMaterial.h"
#include "FITKAbaqusHDF5AdaptorSection.h"
#include "FITKAbaqusHDF5AdaptorProfile.h"
#include "FITKAbaqusHDF5AdaptorAssembly.h"
#include "FITKAbaqusHDF5AdaptorStep.h"
#include "FITKAbaqusHDF5AdaptorOutput.h"
#include "FITKAbaqusHDF5AdaptorLoad.h"
#include "FITKAbaqusHDF5AdaptorAmplitude.h"
#include "FITKAbaqusHDF5AdaptorInteraction.h"
#include "FITKAbaqusHDF5AdaptorInteractionProperty.h"
#include "FITKAbaqusHDF5AdaptorBoundary.h"
#include "FITKAbaqusHDF5AdaptorConstraint.h"
#include "FITKAbaqusHDF5AdaptorTimePoints.h"
#include "FITKAbaqusHDF5AdaptorConnectorSection.h"

#include "FITK_Component/FITKAbaqusData/FITKDataCase.h"
#include "FITK_Component/FITKAbaqusData/FITKAbaqusPart.h"

//Material
#include "FITK_Interface/FITKInterfacePhysics/FITKAbstractMaterial.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaMaterial.h"

//Section
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaAbstractSection.h"
#include "FITK_Interface/FITKInterfacePhysics/FITKSectionAssign.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaSectionBeam.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaSectionShellHomogeneous.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaSectionSolidHomogeneous.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaSectionAssignShellHomogeneous.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaSectionAssignSolidHomogenous.h"

//profile
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaProfile.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaProfileI.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaProfileL.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaProfileCircular.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaProfilePipe.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaProfileRectangular.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaProfileBox.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaProfileManager.h"

//output
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaAbstractOutput.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaFieldOutputManager.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaHistoryOutputManager.h"


//load
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaLoadManager.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaAbstractLoad.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaLoadConcentratedForce.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaLoadPressure.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaLoadMoment.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaLoadBodyForce.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaLoadGravity.h"

//constraint
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaConstraintManager.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaAbstractConstraint.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaConstraintTie.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaConstraintRigidBody.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaConstraintCoupling.h"

//timePoints
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaTimePoints.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaTimePointsManager.h"

//ConnectorSection
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaConnectorSectionManager.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaConnectorSection.h"

#include "FITK_Interface/FITKInterfaceStructural/FITKAbaAssembly.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaAbstractStep.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaStepInit.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaStepFrequency.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaStepGeneralStatic.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaStepDynamicExplicit.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaStepManager.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaAbstractAmplitude.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaAmplitudePeriodic.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaAmplitudeTabular.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaAmplitudeManager.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaAbstractBoundaryCondition.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaBoundaryConditionDisplacement.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaBoundaryConditionSymmetry.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaBoundaryConditionVelocity.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaInteractionPropertyContact.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaInteractionPropertyManager.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaBoundaryConditionManager.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaInteractionSurfToSurfExplicit.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaInteractionGeneralContactExplicit.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaInteractionManager.h"
#include "FITK_Interface/FITKInterfacePhysics/FITKAbstractLoadBC.h"

#include "H5Cpp.h"
#include <QDebug>
namespace IO
{
    QString FITKAbaqusHDF5AdaptorCase::getAdaptorClass()
    {
        return "FITKAbaqusHDF5AdaptorCase";
    }

    bool FITKAbaqusHDF5AdaptorCase::adaptR()
    {
        _caseData = AbaqusData::FITKDataCase::SafeDownCastFITKDataCase(_dataObj);
        if (!_reader || !_caseData) return false;
        bool isR = true;
        int level = 1;
        QString str;
        isR &= readDataCaseInfo(*_h5Group);

        _reader->consoleMessage(1, "CaseName : " + _caseData->getDataObjectName());

        //读取Materials节点
        if (_h5Group->nameExists("Materials"))
        {
            H5::Group materialsGroup = _h5Group->openGroup("Materials");
            int materialsCount = materialsGroup.getNumAttrs();
            for (int i = 0; i < materialsCount; ++i)
            {
                QString indexName = QString::number(i);
                if (!materialsGroup.attrExists(indexName.toStdString())) continue;

                auto materialName = readStrAttribute(materialsGroup, indexName.toStdString());
                auto materialGroup = materialsGroup.openGroup(materialName);
                isR &= readMaterial(materialGroup);
            }
            consoleMessage(isR, "Read Materials Status : ");
        }

        //读取Section节点
        if (_h5Group->nameExists("Sections"))
        {
            H5::Group sctionsGroup = _h5Group->openGroup("Sections");
            int sctionsCount = sctionsGroup.getNumAttrs();
            for (int i = 0; i < sctionsCount; ++i)
            {
                if (!sctionsGroup.attrExists(std::to_string(i))) continue;

                auto sctionName = readStrAttribute(sctionsGroup, std::to_string(i));
                auto sctionGroup = sctionsGroup.openGroup(sctionName);
                isR &= readSection(sctionGroup);
            }
            _reader->consoleMessage(isR, "Read Sections Status : ");
        }

        //读取_connector Section节点
        if (_h5Group->nameExists("ConnectorSections"))
        {
            H5::Group ConnectorSectionsGroup = _h5Group->openGroup("ConnectorSections");
            int sctionsCount = ConnectorSectionsGroup.getNumAttrs();
            for (int i = 0; i < sctionsCount; ++i)
            {
                if (!ConnectorSectionsGroup.attrExists(std::to_string(i))) continue;

                auto sctionName = readStrAttribute(ConnectorSectionsGroup, std::to_string(i));
                auto ConnectorSectionGroup = ConnectorSectionsGroup.openGroup(sctionName);
                isR &= readConnectorSection(ConnectorSectionGroup);
            }
            level = isR ? 1 : 3;
            str = isR ? "True" : "False";
            _reader->consoleMessage(level, "Read ConnectorSections Status : " + str);
        }

        //读取Parts节点
        if (_h5Group->nameExists("Parts"))
        {
            H5::Group partsGroup = _h5Group->openGroup("Parts");
            int partCount = partsGroup.getNumAttrs();
            for (int i = 0; i < partCount; ++i)
            {
                if (!partsGroup.attrExists(std::to_string(i))) continue;
                auto partName = readStrAttribute(partsGroup, std::to_string(i));
                auto partGroup = partsGroup.openGroup(partName);
                isR &= readPart(partGroup);
            }
            level = isR ? 1 : 3;
            str = isR ? "True" : "False";
            _reader->consoleMessage(level, "Read Parts Status : " + str);
        }

        //读取Profile节点
        if (_h5Group->nameExists("Profiles"))
        {
            H5::Group profilesGroup = _h5Group->openGroup("Profiles");
            int profilesCount = profilesGroup.getNumAttrs();
            for (int i = 0; i < profilesCount; ++i)
            {
                if (!profilesGroup.attrExists(std::to_string(i))) continue;
                auto profileName = readStrAttribute(profilesGroup, std::to_string(i));
                auto profileGroup = profilesGroup.openGroup(profileName);
                isR &= readProfile(profileGroup);
            }
            level = isR ? 1 : 3;
            str = isR ? "True" : "False";
            _reader->consoleMessage(level, "Read Profiles Status : " + str);
        }

        //读取Assembly节点
        if (_h5Group->nameExists("Assembly"))
        {
            H5::Group assemblyGroup = _h5Group->openGroup("Assembly");
            int assemblyAtrrCount = assemblyGroup.getNumAttrs();
            if (assemblyAtrrCount != 0)
            {
                isR &= readAssembly(_caseData->getAssembly(), assemblyGroup);
                level = isR ? 1 : 3;
                str = isR ? "True" : "False";
            }
            _reader->consoleMessage(level, "Read Assembly Status : " + str);
        }

        //读取Steps节点
        if (_h5Group->nameExists("Steps"))
        {
            H5::Group stepsGroup = _h5Group->openGroup("Steps");
            int stepsCount = stepsGroup.getNumAttrs();
            for (int i = 0; i < stepsCount; ++i)
            {
                if (!stepsGroup.attrExists(std::to_string(i))) continue;
                auto stepName = readStrAttribute(stepsGroup, std::to_string(i));
                auto stepGroup = stepsGroup.openGroup(stepName);
                isR &= readStep(stepGroup);
            }

            level = isR ? 1 : 3;
            str = isR ? "True" : "False";
            _reader->consoleMessage(level, "Read Steps Status : " + str);
        }
        //读取FiledOutput节点
        if (_h5Group->nameExists("FiledOutputs"))
        {
            H5::Group filedOutputsGroup = _h5Group->openGroup("FiledOutputs");
            int filedOutputsCount = filedOutputsGroup.getNumAttrs();
            for (int i = 0; i < filedOutputsCount; ++i)
            {
                if (!filedOutputsGroup.attrExists(std::to_string(i))) continue;
                auto name = readStrAttribute(filedOutputsGroup, std::to_string(i));
                auto filedOutputGroup = filedOutputsGroup.openGroup(name);
                isR &= readOutput(filedOutputGroup);
            }
            level = isR ? 1 : 3;
            str = isR ? "True" : "False";
            _reader->consoleMessage(level, "Read Outputs Status : " + str);
        }

        //读取HistoryOutput节点
        if (_h5Group->nameExists("HistoryOutputs"))
        {
            H5::Group historyOutputsGroup = _h5Group->openGroup("HistoryOutputs");
            int historyOutputsCount = historyOutputsGroup.getNumAttrs();
            for (int i = 0; i < historyOutputsCount; ++i)
            {
                if (!historyOutputsGroup.attrExists(std::to_string(i))) continue;
                auto name = readStrAttribute(historyOutputsGroup, std::to_string(i));
                auto historyOutputGroup = historyOutputsGroup.openGroup(name);
                isR &= readOutput(historyOutputGroup);
            }
            level = isR ? 1 : 3;
            str = isR ? "True" : "False";
            _reader->consoleMessage(level, "Read Outputs Status : " + str);
        }

        //读取Loads节点
        if (_h5Group->nameExists("Loads"))
        {
            H5::Group loadsGroup = _h5Group->openGroup("Loads");
            int loadsCount = loadsGroup.getNumAttrs();
            for (int i = 0; i < loadsCount; ++i)
            {
                if (!loadsGroup.attrExists(std::to_string(i))) continue;
                auto name = readStrAttribute(loadsGroup, std::to_string(i));
                auto loadGroup = loadsGroup.openGroup(name);
                isR &= readLoad(loadGroup);
            }
            level = isR ? 1 : 3;
            str = isR ? "True" : "False";
            _reader->consoleMessage(level, "Read Loads Status : " + str);
        }

        //读取Amplitudes节点
        if (_h5Group->nameExists("Amplitudes"))
        {
            H5::Group AmplitudesGroup = _h5Group->openGroup("Amplitudes");
            int amplitudesCount = AmplitudesGroup.getNumAttrs();
            for (int i = 0; i < amplitudesCount; ++i)
            {
                if (!AmplitudesGroup.attrExists(std::to_string(i))) continue;
                auto name = readStrAttribute(AmplitudesGroup, std::to_string(i));
                auto AmplitudeGroup = AmplitudesGroup.openGroup(name);
                isR &= readAmplitude(AmplitudeGroup);
            }
            level = isR ? 1 : 3;
            str = isR ? "True" : "False";
            _reader->consoleMessage(level, "Read Amplitudes Status : " + str);
        }

        //读取InteractionProperty节点
        if (_h5Group->nameExists("InteractionPropertys"))
        {
            H5::Group InteractionPropertysGroup = _h5Group->openGroup("InteractionPropertys");
            int InteractionPropertysCount = InteractionPropertysGroup.getNumAttrs();
            for (int i = 0; i < InteractionPropertysCount; ++i)
            {
                if (!InteractionPropertysGroup.attrExists(std::to_string(i))) continue;
                auto name = readStrAttribute(InteractionPropertysGroup, std::to_string(i));
                auto InteractionPropertyGroup = InteractionPropertysGroup.openGroup(name);
                isR &= readInteractionProperty(InteractionPropertyGroup);
            }
            level = isR ? 1 : 3;
            str = isR ? "True" : "False";
            _reader->consoleMessage(level, "Read InteractionPropertys Status : " + str);
        }

        //读取Interactions节点
        if (_h5Group->nameExists("Interactions"))
        {
            H5::Group InteractionsGroup = _h5Group->openGroup("Interactions");
            int interactionsCount = InteractionsGroup.getNumAttrs();
            for (int i = 0; i < interactionsCount; ++i)
            {
                if (!InteractionsGroup.attrExists(std::to_string(i))) continue;
                auto name = readStrAttribute(InteractionsGroup, std::to_string(i));
                auto InteractionGroup = InteractionsGroup.openGroup(name);
                isR &= readInteraction(InteractionGroup);
            }
            level = isR ? 1 : 3;
            str = isR ? "True" : "False";
            _reader->consoleMessage(level, "Read Interactions Status : " + str);
        }

        //读取Boundarys节点
        if (_h5Group->nameExists("Boundarys"))
        {
            H5::Group boundarysGroup = _h5Group->openGroup("Boundarys");
            int boundarysCount = boundarysGroup.getNumAttrs();
            for (int i = 0; i < boundarysCount; ++i)
            {
                if (!boundarysGroup.attrExists(std::to_string(i))) continue;
                auto name = readStrAttribute(boundarysGroup, std::to_string(i));
                auto boundaryGroup = boundarysGroup.openGroup(name);
                isR &= readBoundary(boundaryGroup);
            }
            level = isR ? 1 : 3;
            str = isR ? "True" : "False";
            _reader->consoleMessage(level, "Read Boundarys Status : " + str);
        }

        //读取Constraint节点
        if (_h5Group->nameExists("Constraints"))
        {
            H5::Group constraintsGroup = _h5Group->openGroup("Constraints");
            int constraintsCount = constraintsGroup.getNumAttrs();
            for (int i = 0; i < constraintsCount; ++i)
            {
                if (!constraintsGroup.attrExists(std::to_string(i))) continue;
                auto name = readStrAttribute(constraintsGroup, std::to_string(i));
                auto constraintGroup = constraintsGroup.openGroup(name);
                isR &= readConstraint(constraintGroup);
            }
            level = isR ? 1 : 3;
            str = isR ? "True" : "False";
            _reader->consoleMessage(level, "Read Constraints Status : " + str);
        }

        //读取TimePoints节点
        if (_h5Group->nameExists("TimePoints"))
        {
            H5::Group timePointsGroup = _h5Group->openGroup("TimePoints");
            auto timePointNum = _caseData->getTimePointsManager()->getDataCount();
            int timePointsCount = timePointsGroup.getNumAttrs();
            for (int i = 0; i < timePointsCount; ++i)
            {
                if (!timePointsGroup.attrExists(std::to_string(i))) continue;
                auto name = readStrAttribute(timePointsGroup, std::to_string(i));
                auto constraintGroup = timePointsGroup.openGroup(name);
                isR &= readTimePoints(constraintGroup);
            }
            level = isR ? 1 : 3;
            str = isR ? "True" : "False";
            _reader->consoleMessage(level, "Read TimePoints Status : " + str);
        }
        return isR;
    }

    bool FITKAbaqusHDF5AdaptorCase::adaptW()
    {
        _caseData = AbaqusData::FITKDataCase::SafeDownCastFITKDataCase(_dataObj);
        if (!_writer || !_caseData) return false;
        bool isW = true, w = true;

        //按照算例名字创建节点
        std::string groupName = createParentAttribute(_caseData, *_h5Group);
        if (groupName.empty())return false;

        H5::Group caseGroup = _h5Group->createGroup(groupName);
        _writer->consoleMessage(1, "CaseName : " + QString::fromStdString(groupName));

        //写出算例信息
        writeDataCaseInfo(caseGroup);

        //创建Parts节点
        H5::Group partGroup = caseGroup.createGroup("Parts");
        int partNum = _caseData->getPartManager()->getDataCount();
        for (int i = 0; i < partNum; ++i)
        {
            auto part = _caseData->getPartManager()->getDataByIndex(i);
            isW &= writePart(part, partGroup);
        }

        //创建Material节点
        H5::Group materialGroup = caseGroup.createGroup("Materials");
        int materialNum = _caseData->getMaterialManager()->getDataCount();
        for (int i = 0; i < materialNum; ++i)
        {
            auto material = _caseData->getMaterialManager()->getDataByIndex(i);
            auto mat = dynamic_cast<Interface::FITKAbaMaterial*>(material);
            isW &= writeMaterial(mat, materialGroup);
        }

        //创建Section节点
        H5::Group sectionGroup = caseGroup.createGroup("Sections");
        int sectionNum = _caseData->getSectionManager()->getDataCount();
        for (int i = 0; i < sectionNum; ++i)
        {
            auto section = _caseData->getSectionManager()->getDataByIndex(i);
            auto sectionObject = dynamic_cast<Interface::FITKAbaAbastractSection*>(section);
            isW &= writeSection(sectionObject, sectionGroup);
        }

        //创建ConnectorSection节点
        H5::Group connectorSectionsGroup = caseGroup.createGroup("ConnectorSections");
        int connectorSectionsNum = _caseData->getConnectorSectionManager()->getDataCount();
        for (int i = 0; i < connectorSectionsNum; ++i)
        {
            auto connectorSection = _caseData->getConnectorSectionManager()->getDataByIndex(i);
            auto connectorSectionObject = dynamic_cast<Interface::FITKAbaConnectorSection*>(connectorSection);
            isW &= writeConnectorSection(connectorSectionObject, connectorSectionsGroup);
        }

        //创建Profile节点
        H5::Group profileGroup = caseGroup.createGroup("Profiles");
        int profileNum = _caseData->getProfileManager()->getDataCount();
        for (int i = 0; i < profileNum; ++i)
        {
            auto profile = _caseData->getProfileManager()->getDataByIndex(i);
            auto profileObject = dynamic_cast<Interface::FITKAbaProfile*>(profile);
            isW &= writeProfile(profileObject, profileGroup);
        }

        //创建Assembly节点
        H5::Group assemblyGroup = caseGroup.createGroup("Assembly");
        auto assemblyNum = _caseData->getAssembly()->getDataCount();
        if (assemblyNum > 0)
        {
            auto absAssembly = _caseData->getAssembly();
            isW &= writeAssembly(absAssembly, assemblyGroup);
        }

        //创建Step节点
        H5::Group stepGroup = caseGroup.createGroup("Steps");
        auto stepNum = _caseData->getStepManager()->getDataCount();
        for (int i = 0; i < stepNum; ++i)
        {
            auto step = _caseData->getStepManager()->getDataByIndex(i);
            isW &= writeStep(step, stepGroup);
        }

        //创建FiledOutput节点
        H5::Group fieldOutputGroup = caseGroup.createGroup("FiledOutputs");
        auto fieldNum = _caseData->getFieldOutputManager()->getDataCount();
        for (int i = 0; i < fieldNum; ++i)
        {
            auto fieldOutput = _caseData->getFieldOutputManager()->getDataByIndex(i);
            isW &= writeOutput(fieldOutput, fieldOutputGroup);
        }

        //创建HistoryOutput节点
        H5::Group historyOutputGroup = caseGroup.createGroup("HistoryOutputs");
        auto historyNum = _caseData->getFieldOutputManager()->getDataCount();
        for (int i = 0; i < historyNum; ++i)
        {
            auto historyOutput = _caseData->getHistoryOutputManager()->getDataByIndex(i);
            isW &= writeOutput(historyOutput, historyOutputGroup);
        }

        //创建Load节点
        H5::Group LoadGroup = caseGroup.createGroup("Loads");
        auto loadNum = _caseData->getLoadManager()->getDataCount();
        for (int i = 0; i < loadNum; ++i)
        {
            auto load = _caseData->getLoadManager()->getDataByIndex(i);
            isW &= writeLoad(load, LoadGroup);
        }

        //创建Amplitude节点
        H5::Group AmplitudeGroup = caseGroup.createGroup("Amplitudes");
        auto ampNum = _caseData->getAmplitudeManager()->getDataCount();
        for (int i = 0; i < ampNum; ++i)
        {
            auto Amplitude = _caseData->getAmplitudeManager()->getDataByIndex(i);
            isW &= writeAmplitude(Amplitude, AmplitudeGroup);
        }

        //创建Interaction节点
        H5::Group InteractionGroup = caseGroup.createGroup("Interactions");
        auto InteractionNum = _caseData->getInteractionManager()->getDataCount();
        for (int i = 0; i < InteractionNum; ++i)
        {
            auto Interaction = _caseData->getInteractionManager()->getDataByIndex(i);
            isW &= writeInteraction(Interaction, InteractionGroup);
        }

        //创建InteractionProperty节点
        H5::Group InteractioPropertyGroup = caseGroup.createGroup("InteractionPropertys");
        auto InteractionPropertyNum = _caseData->getInteractionManager()->getDataCount();
        for (int i = 0; i < InteractionPropertyNum; ++i)
        {
            auto InteractionProperty = _caseData->getInteractionPropertyManager()->getDataByIndex(i);
            isW &= writeInteractionProperty(InteractionProperty, InteractioPropertyGroup);
        }

        //创建Boundary节点
        H5::Group BoundarysGroup = caseGroup.createGroup("Boundarys");
        auto BoundaryNum = _caseData->getBCManager()->getDataCount();
        for (int i = 0; i < BoundaryNum; ++i)
        {
            auto bc = _caseData->getBCManager()->getDataByIndex(i);
            isW &= writeBoundary(bc, BoundarysGroup);
        }

        //创建Constraint节点
        H5::Group ConstraintGroup = caseGroup.createGroup("Constraints");
        auto ConstraintNum = _caseData->getConstraintManager()->getDataCount();
        for (int i = 0; i < ConstraintNum; ++i)
        {
            auto Constraint = _caseData->getConstraintManager()->getDataByIndex(i);
            isW &= writeConstraint(Constraint, ConstraintGroup);
        }

        //写出TimePoints节点
        H5::Group TimePointsGroup = caseGroup.createGroup("TimePoints");
        auto timePointNum = _caseData->getTimePointsManager()->getDataCount();
        for (int i = 0; i < timePointNum; ++i)
        {
            auto timePoint = _caseData->getTimePointsManager()->getDataByIndex(i);
            isW &= writeTimePoints(timePoint, TimePointsGroup);
        }

        return true;
    }

    bool FITKAbaqusHDF5AdaptorCase::readPart(H5::Group& partGroup)
    {
        auto part = new AbaqusData::FITKAbaqusPart();
        _caseData->getPartManager()->appendDataObj(part);
        if (!part) return false;
        //部件读取器
        FITKAbaqusHDF5AdaptorPart* adaptor = FITKIOADAPTORFACTORY->createT<FITKAbaqusHDF5AdaptorPart>("HDF5", part);
        if (adaptor == nullptr)
        {
            return false;
        }
        adaptor->setDataObject(part);
        adaptor->setFileReader(_reader);
        adaptor->setH5GroupData(partGroup);
        bool isR = adaptor->adaptR();
        delete adaptor;

        return isR;
    }

    bool FITKAbaqusHDF5AdaptorCase::readMaterial(H5::Group& h5Group)
    {
        if (!_caseData) return false;
        Interface::FITKAbaMaterial* material = new Interface::FITKAbaMaterial;
        _caseData->getMaterialManager()->appendDataObj(material);
        //material adaptor
        FITKAbaqusHDF5AdaptorMaterial* adaptor = FITKIOADAPTORFACTORY->createT<FITKAbaqusHDF5AdaptorMaterial>("HDF5", material);
        if (adaptor == nullptr)
        {
            return false;
        }
        adaptor->setDataObject(material);
        adaptor->setFileReader(_reader);
        adaptor->setH5GroupData(h5Group);
        bool isR = adaptor->adaptR();
        delete adaptor;
        if (!isR) delete material;
        return isR;
    }

    bool FITKAbaqusHDF5AdaptorCase::readSection(H5::Group& h5Group)
    {
        if (!h5Group.attrExists("Type"))return false;
        auto strType = readStrAttribute(h5Group, "Type");

        //字符转换枚举
        Core::FITKEnumTransfer<Interface::FITKAbaAbastractSection::FITKAbaSectionType> fitkTypeTrafer;
        bool isValid = false;
        //写出类型
        auto eSectionType = fitkTypeTrafer.fromString(QString::fromStdString(strType), isValid);
        if (!isValid) return false;
        Interface::FITKAbaAbastractSection* section;

        if (eSectionType == Interface::FITKAbaAbastractSection::FITKAbaSectionType::Beam)
        {
            section = new Interface::FITKAbaSectionBeam;
        }
        else if (eSectionType == Interface::FITKAbaAbastractSection::FITKAbaSectionType::ShellHomogeneous)
        {
            section = new Interface::FITKAbaSectionShellHomogeneous;
        }
        else if (eSectionType == Interface::FITKAbaAbastractSection::FITKAbaSectionType::SolidHomogeneous)
        {
            section = new Interface::FITKAbaSectionSolidHomogeneous;
        }
        else if (eSectionType == Interface::FITKAbaAbastractSection::FITKAbaSectionType::Truss)
        {
            return false;
        }
        if (!section) return false;
        _caseData->getSectionManager()->appendDataObj(section);

        //section adaptor
        FITKAbaqusHDF5AdaptorSection* adaptor = FITKIOADAPTORFACTORY->createT<FITKAbaqusHDF5AdaptorSection>("HDF5", "Interface::FITKAbaAbastractSection");
        if (adaptor == nullptr)
        {
            return false;
        }
        adaptor->setDataObject(section);
        adaptor->setFileReader(_reader);
        adaptor->setH5GroupData(h5Group);
        bool isR = adaptor->adaptR();
        if (!isR) delete section;
        delete adaptor;
        return isR;
    }

    bool FITKAbaqusHDF5AdaptorCase::readProfile(H5::Group& h5Group)
    {
        if (!_caseData) return false;
        if (!h5Group.attrExists("Type"))return false;
        bool isR = true;
        auto typeStr = readStrAttribute(h5Group, "Type");
        //枚举转换字符
        Core::FITKEnumTransfer<Interface::FITKAbaProfile::FITKAbaProfileShape> fitkTypeTrafer;
        bool isValid = false;
        //写出类型
        auto Type = fitkTypeTrafer.fromString(QString::fromStdString(typeStr), isValid);
        if (!isValid) return false;
        Interface::FITKAbaProfile* profile;
        switch (Type)
        {
        case Interface::FITKAbaProfile::FITKAbaProfileShape::Box:
        {
            profile = new Interface::FITKAbaProfileBox();
        }break;
        case Interface::FITKAbaProfile::FITKAbaProfileShape::Circular:
        {
            profile = new Interface::FITKAbaProfileCircular();
        }break;
        case Interface::FITKAbaProfile::FITKAbaProfileShape::I:
        {
            profile = new Interface::FITKAbaProfileI();
        }break;
        case Interface::FITKAbaProfile::FITKAbaProfileShape::L:
        {
            profile = new Interface::FITKAbaProfileL();
        }break;
        case Interface::FITKAbaProfile::FITKAbaProfileShape::Pipe:
        {
            profile = new Interface::FITKAbaProfilePipe();
        }break;
        case Interface::FITKAbaProfile::FITKAbaProfileShape::Rectangular:
        {
            profile = new Interface::FITKAbaProfileRectangular();
        }break;
        default:
            break;
        }
        if (!profile) return false;
        _caseData->getProfileManager()->appendDataObj(profile);
        //profile adaptor
        FITKAbaqusHDF5AdaptorProfile* adaptor = FITKIOADAPTORFACTORY->createT<FITKAbaqusHDF5AdaptorProfile>("HDF5", "Interface::FITKAbaProfile");
        if (adaptor == nullptr)
        {
            return false;
        }
        adaptor->setDataObject(profile);
        adaptor->setFileReader(_reader);
        adaptor->setH5GroupData(h5Group);
        isR &= adaptor->adaptR();
        delete adaptor;
        if (!isR) delete profile;
        return isR;
    }

    bool FITKAbaqusHDF5AdaptorCase::readAssembly(Interface::FITKAbaAssembly* assembly, H5::Group& h5Group)
    {
        if (!assembly) return false;
        bool isR = true;
        //profile adaptor
        FITKAbaqusHDF5AdaptorAssembly* adaptor = FITKIOADAPTORFACTORY->createT<FITKAbaqusHDF5AdaptorAssembly>("HDF5", "Interface::FITKAbaAssembly");
        if (adaptor == nullptr)
        {
            return false;
        }
        adaptor->setDataObject(assembly);
        adaptor->setFileReader(_reader);
        adaptor->setH5GroupData(h5Group);
        isR = adaptor->adaptR();
        delete adaptor;
        return isR;
    }

    bool FITKAbaqusHDF5AdaptorCase::readStep(H5::Group& h5Group)
    {
        if (!_caseData) return false;
        if (!h5Group.attrExists("Type"))return false;
        auto typeStr = readStrAttribute(h5Group, "Type");
        //枚举转换字符
        Core::FITKEnumTransfer<Interface::FITKAbaAbstractStep::FITKAbaStepType> fitkTypeTrafer;
        bool isValid = false;
        //写出类型
        auto Type = fitkTypeTrafer.fromString(QString::fromStdString(typeStr), isValid);
        if (!isValid) return false;
        Interface::FITKAbaAbstractStep* step{};

        switch (Type)
        {
        case Interface::FITKAbaAbstractStep::Init:
            step = _caseData->getStepManager()->getDataByIndex(0);
            break;
        case Interface::FITKAbaAbstractStep::Buckle:
            //step = new Interface:;
            return false;
            break;
        case Interface::FITKAbaAbstractStep::Frequency:
            step = new Interface::FITKAbaStepFrequency();
            _caseData->getStepManager()->appendDataObj(step);
            break;
        case Interface::FITKAbaAbstractStep::DynamicExplicit:
            step = new Interface::FITKAbaStepDynamicExplicit();
            _caseData->getStepManager()->appendDataObj(step);
            break;
        case Interface::FITKAbaAbstractStep::GeneralStatic:
            step = new Interface::FITKAbaStepGeneralStatic();
            _caseData->getStepManager()->appendDataObj(step);
            break;
        default:
            break;
        }
        if (!step) return false;

        //Step adaptor
        FITKAbaqusHDF5AdaptorStep* adaptor = FITKIOADAPTORFACTORY->createT<FITKAbaqusHDF5AdaptorStep>("HDF5", "Interface::FITKAbaAbstractStep");
        if (adaptor == nullptr)
        {
            return false;
        }
        adaptor->setDataObject(step);
        adaptor->setFileReader(_reader);
        adaptor->setH5GroupData(h5Group);
        bool isR = adaptor->adaptR();
        delete adaptor;
        return isR;
    }

    bool FITKAbaqusHDF5AdaptorCase::readOutput(H5::Group& h5Group)
    {
        if (!_caseData) return false;
        if (!h5Group.attrExists("Type"))return false;
        auto typeStr = readStrAttribute(h5Group, "Type");
        //枚举转换字符
        Core::FITKEnumTransfer<Interface::FITKAbaAbstractOutput::FITKAbaOutputType> fitkTypeTrafer;
        bool isValid = false;
        //写出类型
        auto Type = fitkTypeTrafer.fromString(QString::fromStdString(typeStr), isValid);
        if (!isValid) return false;
        Interface::FITKAbaAbstractOutput* output{};

        switch (Type)
        {
        case Interface::FITKAbaAbstractOutput::FITKAbaOutputType::Field:
            output = new Interface::FITKAbaFieldOutput();
            _caseData->getFieldOutputManager()->appendDataObj(output);
            break;
        case Interface::FITKAbaAbstractOutput::FITKAbaOutputType::History:
            output = new Interface::FITKAbaHistoryOutput();
            _caseData->getHistoryOutputManager()->appendDataObj(output);

            break;

        default:
            break;
        }
        if (!output) return false;

        //Output adaptor
        FITKAbaqusHDF5AdaptorOutput* adaptor = FITKIOADAPTORFACTORY->createT<FITKAbaqusHDF5AdaptorOutput>("HDF5", "Interface::FITKAbaAbstractOutput");
        if (adaptor == nullptr)
        {
            return false;
        }
        adaptor->setDataObject(output);
        adaptor->setStepManager(_caseData->getStepManager());
        adaptor->setFileReader(_reader);
        adaptor->setH5GroupData(h5Group);
        bool isR = adaptor->adaptR();
        delete adaptor;
        if (!isR) delete output;
        return isR;
    }

    bool FITKAbaqusHDF5AdaptorCase::readLoad(H5::Group& h5Group)
    {
        if (!_caseData) return false;
        if (!h5Group.attrExists("Type"))return false;
        auto typeStr = readStrAttribute(h5Group, "Type");
        //枚举转换字符
        Core::FITKEnumTransfer<Interface::FITKAbaAbstractLoad::FITKAbaLoadType> fitkTypeTrafer;
        bool isValid = false;
        //写出类型
        auto Type = fitkTypeTrafer.fromString(QString::fromStdString(typeStr), isValid);
        if (!isValid) return false;
        Interface::FITKAbaAbstractLoad* load{};

        switch (Type)
        {
        case Interface::FITKAbaAbstractLoad::FITKAbaLoadType::BodyForce:
            load = new Interface::FITKAbaLoadBodyForce();
            break;

        case Interface::FITKAbaAbstractLoad::FITKAbaLoadType::ConcentratedForce:
            load = new Interface::FITKAbaLoadConcentratedForce();
            break;

        case Interface::FITKAbaAbstractLoad::FITKAbaLoadType::Gravity:
            load = new Interface::FITKAbaLoadGravity();
            break;

        case Interface::FITKAbaAbstractLoad::FITKAbaLoadType::Moment:
            load = new Interface::FITKAbaLoadMoment();
            break;

        case Interface::FITKAbaAbstractLoad::FITKAbaLoadType::Pressure:
            load = new Interface::FITKAbaLoadPressure();
            break;
        default:
            break;
        }

        if (!load) return false;
        _caseData->getLoadManager()->appendDataObj(load);

        //Load adaptor
        FITKAbaqusHDF5AdaptorLoad* adaptor = FITKIOADAPTORFACTORY->createT<FITKAbaqusHDF5AdaptorLoad>("HDF5", "Interface::FITKAbaAbstractLoad");
        if (adaptor == nullptr)
        {
            return false;
        }
        adaptor->setDataObject(load);
        adaptor->setDataCase(_caseData);
        adaptor->setFileReader(_reader);
        adaptor->setH5GroupData(h5Group);
        bool isR = adaptor->adaptR();
        delete adaptor;
        return isR;
    }

    bool FITKAbaqusHDF5AdaptorCase::readAmplitude(H5::Group& h5Group)
    {
        if (!h5Group.attrExists("AmplitudeType"))return false;
        auto typeStr = readStrAttribute(h5Group, "AmplitudeType");
        //枚举转换字符
        Core::FITKEnumTransfer<Interface::FITKAbaAbstractAmplitude::FITKAbaAmplitudeType> fitkTypeTrafer;
        bool isValid = false;
        //写出类型
        auto Type = fitkTypeTrafer.fromString(QString::fromStdString(typeStr), isValid);
        if (!isValid) return false;
        Interface::FITKAbaAbstractAmplitude* amplitude{};

        switch (Type)
        {
        case Interface::FITKAbaAbstractAmplitude::FITKAbaAmplitudeType::Periodic:
            amplitude = new Interface::FITKAbaAmplitudePeriodic;
            break;
        case Interface::FITKAbaAbstractAmplitude::FITKAbaAmplitudeType::Tabular:
            amplitude = new Interface::FITKAbaAmplitudeTabular;
            break;
        default:
            break;
        }
        if (!amplitude) return false;
        _caseData->getAmplitudeManager()->appendDataObj(amplitude);

        //Amplitude adaptor
        FITKAbaqusHDF5AdaptorAmplitude* adaptor = FITKIOADAPTORFACTORY->createT<FITKAbaqusHDF5AdaptorAmplitude>("HDF5", "Interface::FITKAbstractAmplitude");
        if (adaptor == nullptr)
        {
            return false;
        }
        adaptor->setDataObject(amplitude);
        adaptor->setFileReader(_reader);
        adaptor->setH5GroupData(h5Group);
        bool isR = adaptor->adaptR();
        delete adaptor;
        return isR;
    }

    bool FITKAbaqusHDF5AdaptorCase::readInteraction(H5::Group& h5Group)
    {
        if (!h5Group.attrExists("Type"))return false;
        auto typeStr = readStrAttribute(h5Group, "Type");
        //枚举转换字符
        Core::FITKEnumTransfer<Interface::FITKAbaAbstractInteraction::FITKAbaInteractionType> fitkTypeTrafer;
        bool isValid = false;
        //写出类型
        auto Type = fitkTypeTrafer.fromString(QString::fromStdString(typeStr), isValid);
        if (!isValid) return false;
        Interface::FITKAbaAbstractInteraction* interaction{};

        switch (Type)
        {
        case Interface::FITKAbaAbstractInteraction::FITKAbaInteractionType::SurfToSurfContactExplicit:
            interaction = new Interface::FITKAbaInteractionSurfToSurfExplicit;
            break;
        case Interface::FITKAbaAbstractInteraction::FITKAbaInteractionType::GeneralContactExplicit:
            interaction = new Interface::FITKAbaInteractionGeneralContactExplicit;
            break;
        default:
            break;
        }
        if (!interaction) return false;
        _caseData->getInteractionManager()->appendDataObj(interaction);

        //Interaction adaptor
        FITKAbaqusHDF5AdaptorInteraction* adaptor = FITKIOADAPTORFACTORY->createT<FITKAbaqusHDF5AdaptorInteraction>("HDF5", "Interface::FITKAbaAbstractInteraction");
        if (adaptor == nullptr)
        {
            return false;
        }
        adaptor->setDataCase(_caseData);
        adaptor->setDataObject(interaction);
        adaptor->setFileReader(_reader);
        adaptor->setH5GroupData(h5Group);
        bool isR = adaptor->adaptR();
        delete adaptor;
        if (!isR) delete interaction;
        return isR;
    }

    bool FITKAbaqusHDF5AdaptorCase::readInteractionProperty(H5::Group& h5Group)
    {
        if (!h5Group.attrExists("Type"))return false;
        auto typeStr = readStrAttribute(h5Group, "Type");
        //枚举转换字符
        Core::FITKEnumTransfer<Interface::FITKAbaAbstractInteractionProperty::FITKAbaInteractionPropertyType> fitkTypeTrafer;
        bool isValid = false;
        //写出类型
        auto Type = fitkTypeTrafer.fromString(QString::fromStdString(typeStr), isValid);
        if (!isValid) return false;
        Interface::FITKAbaAbstractInteractionProperty* interactionProperty{};

        switch (Type)
        {
        case Interface::FITKAbaAbstractInteractionProperty::FITKAbaInteractionPropertyType::Contact:
            interactionProperty = new Interface::FITKAbaInteractionPropertyContact;
            break;
        default:
            break;
        }
        if (!interactionProperty) return false;
        _caseData->getInteractionPropertyManager()->appendDataObj(interactionProperty);

        //Amplitude adaptor
        FITKAbaqusHDF5AdaptorInteractionProperty* adaptor = FITKIOADAPTORFACTORY->createT<FITKAbaqusHDF5AdaptorInteractionProperty>("HDF5", "Interface::FITKAbaAbstractInteractionProperty");
        if (adaptor == nullptr)
        {
            return false;
        }
        adaptor->setDataObject(interactionProperty);
        adaptor->setFileReader(_reader);
        adaptor->setH5GroupData(h5Group);
        bool isR = adaptor->adaptR();
        delete adaptor;
        if (!isR) delete interactionProperty;
        return isR;
    }

    bool FITKAbaqusHDF5AdaptorCase::readBoundary(H5::Group& h5Group)
    {
        if (!h5Group.attrExists("Type"))return false;
        auto typeStr = readStrAttribute(h5Group, "Type");
        //枚举转换字符
        Core::FITKEnumTransfer<Interface::FITKAbaAbstractBoundaryCondition::FITKAbaBoundaryConditionType> fitkTypeTrafer;
        bool isValid = false;
        //写出类型
        auto Type = fitkTypeTrafer.fromString(QString::fromStdString(typeStr), isValid);
        if (!isValid) return false;
        Interface::FITKAbaAbstractBoundaryCondition* BoundaryCondition{};

        switch (Type)
        {
        case Interface::FITKAbaAbstractBoundaryCondition::FITKAbaBoundaryConditionType::DisplacementRotation:
            BoundaryCondition = new Interface::FITKAbaBoundaryConditionDisplacement;
            break;
        case Interface::FITKAbaAbstractBoundaryCondition::FITKAbaBoundaryConditionType::SymmetryAntisymmetryEncastre:
            BoundaryCondition = new Interface::FITKAbaBoundaryConditionSymmetry;
            break;
        case Interface::FITKAbaAbstractBoundaryCondition::FITKAbaBoundaryConditionType::VelocityAngularVelocity:
            BoundaryCondition = new Interface::FITKAbaBoundaryConditionVelocity;
            break;
        }
        if (!BoundaryCondition) 
            return false;
        _caseData->getBCManager()->appendDataObj(BoundaryCondition);

        //Amplitude adaptor
        FITKAbaqusHDF5AdaptorBoundary* adaptor = FITKIOADAPTORFACTORY->createT<FITKAbaqusHDF5AdaptorBoundary>("HDF5", "Interface::FITKAbaAbstractBoundaryCondition");
        if (adaptor == nullptr)
        {
            return false;
        }
        adaptor->setDataCase(_caseData);
        adaptor->setDataObject(BoundaryCondition);
        adaptor->setFileReader(_reader);
        adaptor->setH5GroupData(h5Group);
        bool isR = adaptor->adaptR();
        delete adaptor;
        return isR;
    }

    bool FITKAbaqusHDF5AdaptorCase::readConstraint(H5::Group& h5Group)
    {
        if (!h5Group.attrExists("Type"))return false;
        bool isR = true;
        auto typeStr = readStrAttribute(h5Group, "Type");
        //枚举转换字符
        Core::FITKEnumTransfer<Interface::FITKAbaAbstractConstraint::FITKAbaConstraintType> fitkTypeTrafer;
        bool isValid = false;
        //写出类型
        auto Type = fitkTypeTrafer.fromString(QString::fromStdString(typeStr), isValid);
        if (!isValid) return false;
        Interface::FITKAbaAbstractConstraint* constraint{};

        switch (Type)
        {
        case Interface::FITKAbaAbstractConstraint::FITKAbaConstraintType::Coupling:
            constraint = new Interface::FITKAbaConstraintCoupling();
            break;
        case Interface::FITKAbaAbstractConstraint::FITKAbaConstraintType::RigidBody:
            constraint = new Interface::FITKAbaConstraintRigidBody();
            break;
        case Interface::FITKAbaAbstractConstraint::FITKAbaConstraintType::Tie:
            constraint = new Interface::FITKAbaConstraintTie();
            break;
        default:
            break;
        }
        if (!constraint) return false;
        _caseData->getConstraintManager()->appendDataObj(constraint);

        //Amplitude adaptor
        FITKAbaqusHDF5AdaptorConstraint* adaptor = FITKIOADAPTORFACTORY->createT<FITKAbaqusHDF5AdaptorConstraint>("HDF5", "Interface::FITKAbaAbstractConstraint");
        if (adaptor == nullptr)
        {
            return false;
        }
        adaptor->setDataObject(constraint);
        adaptor->setFileReader(_reader);
        adaptor->setH5GroupData(h5Group);
        isR = adaptor->adaptR();
        delete adaptor;
        return isR;
    }

    bool FITKAbaqusHDF5AdaptorCase::readTimePoints(H5::Group& h5Group)
    {
        Interface::FITKAbaTimePoints* timepoints = new Interface::FITKAbaTimePoints();
        if (!timepoints) return false;
        _caseData->getTimePointsManager()->appendDataObj(timepoints);
        bool isR = true;
        //Amplitude adaptor
        auto adaptor = FITKIOADAPTORFACTORY->createT<FITKAbaqusHDF5AdaptorTimePoints>("HDF5", timepoints);
        if (adaptor == nullptr)
        {
            return false;
        }
        adaptor->setDataObject(timepoints);
        adaptor->setFileReader(_reader);
        adaptor->setH5GroupData(h5Group);
        isR &= adaptor->adaptR();
        delete adaptor;
        return isR;
    }

    bool FITKAbaqusHDF5AdaptorCase::readConnectorSection(H5::Group& h5Group)
    {
        Interface::FITKAbaConnectorSection* commectSection = new Interface::FITKAbaConnectorSection();
        _caseData->getConnectorSectionManager()->appendDataObj(commectSection);
        //Amplitude adaptor
        auto adaptor = FITKIOADAPTORFACTORY->createT<FITKAbaqusHDF5AdaptorConnectorSection>("HDF5", commectSection);
        if (adaptor == nullptr) return false;
        adaptor->setDataObject(commectSection);
        adaptor->setFileReader(_reader);
        adaptor->setH5GroupData(h5Group);
        bool isR = adaptor->adaptR();
        delete adaptor;
        if (!isR)
        {
            delete commectSection;
        }
        return isR;
    }

    bool FITKAbaqusHDF5AdaptorCase::readDataCaseInfo(H5::Group& h5group)
    {
        if (!_caseData) return false;
        if (!readNDataObject(_caseData, h5group)) return false;
        _echo = readBoolAttribute(h5group, "Echo");
        _model = readBoolAttribute(h5group, "Model");
        _history = readBoolAttribute(h5group, "History");
        _contact = readBoolAttribute(h5group, "Contact");
        return true;
    }

    bool FITKAbaqusHDF5AdaptorCase::writeDataCaseInfo(H5::Group& h5group)
    {
        if (!_caseData) return false;
        //prePrint
        writeBoolAttribute(h5group, "Echo", &_echo);
        writeBoolAttribute(h5group, "Model", &_model);
        writeBoolAttribute(h5group, "History", &_history);
        writeBoolAttribute(h5group, "Contact", &_contact);
        return writeNDataObject(_caseData, h5group);
    }

    bool FITKAbaqusHDF5AdaptorCase::writePart(AbaqusData::FITKAbaqusPart* part, H5::Group& partGroup)
    {
        if (!part) return false;

        //部件读取器
        FITKAbaqusHDF5AdaptorPart* adaptor = FITKIOADAPTORFACTORY->createT<FITKAbaqusHDF5AdaptorPart>("HDF5", part);
        if (adaptor == nullptr)
        {
            return false;
        }
        adaptor->setDataObject(part);
        adaptor->setFileWriter(_writer);
        adaptor->setH5GroupData(partGroup);
        bool isW = adaptor->adaptW();
        delete adaptor;
        if (isW) _writer->consoleMessage(1, QString("Writer Part OK, Name : %1").arg(part->getDataObjectName()));
        else _writer->consoleMessage(3, QString("Writer Part Error, Name : %1").arg(part->getDataObjectName()));
        return isW;
    }

    bool FITKAbaqusHDF5AdaptorCase::writeMaterial(Interface::FITKAbaMaterial* material, H5::Group& h5Group)
    {
        if (!material) return false;
        //material adaptor
        FITKAbaqusHDF5AdaptorMaterial* adaptor = FITKIOADAPTORFACTORY->createT<FITKAbaqusHDF5AdaptorMaterial>("HDF5", material);
        if (adaptor == nullptr)
        {
            return false;
        }
        adaptor->setDataObject(material);
        adaptor->setFileWriter(_writer);
        adaptor->setH5GroupData(h5Group);
        bool isW = adaptor->adaptW();
        delete adaptor;
        if (isW) _writer->consoleMessage(1, QString("Writer Material OK, Name : %1").arg(material->getDataObjectName()));
        else _writer->consoleMessage(3, QString("Writer Material Error, Name : %1").arg(material->getDataObjectName()));
        return isW;
    }

    bool FITKAbaqusHDF5AdaptorCase::writeSection(Interface::FITKAbaAbastractSection* section, H5::Group& h5Group)
    {
        if (!section) return false;
        //section adaptor
        FITKAbaqusHDF5AdaptorSection* adaptor = FITKIOADAPTORFACTORY->createT<FITKAbaqusHDF5AdaptorSection>("HDF5", "Interface::FITKAbaAbastractSection");
        if (adaptor == nullptr)
        {
            return false;
        }
        adaptor->setDataObject(section);
        adaptor->setFileWriter(_writer);
        adaptor->setH5GroupData(h5Group);
        bool isW = adaptor->adaptW();
        delete adaptor;

        if (isW) _writer->consoleMessage(1, QString("Writer Section OK, Name : %1").arg(section->getDataObjectName()));
        else _writer->consoleMessage(3, QString("Writer Section Error, Name : %1").arg(section->getDataObjectName()));
        return isW;
    }

    bool FITKAbaqusHDF5AdaptorCase::writeProfile(Interface::FITKAbaProfile* profile, H5::Group& h5Group)
    {
        if (!profile) return false;
        //profile adaptor
        FITKAbaqusHDF5AdaptorProfile* adaptor = FITKIOADAPTORFACTORY->createT<FITKAbaqusHDF5AdaptorProfile>("HDF5", "Interface::FITKAbaProfile");
        if (adaptor == nullptr)
        {
            return false;
        }
        adaptor->setDataObject(profile);
        adaptor->setFileWriter(_writer);
        adaptor->setH5GroupData(h5Group);
        bool isW = adaptor->adaptW();
        delete adaptor;

        if (isW) _writer->consoleMessage(1, QString("Writer Profile OK, Name : %1").arg(profile->getDataObjectName()));
        else _writer->consoleMessage(3, QString("Writer Profile Error, Name : %1").arg(profile->getDataObjectName()));
        return isW;
    }

    bool FITKAbaqusHDF5AdaptorCase::writeAssembly(Interface::FITKAbaAssembly * assembly, H5::Group& h5Group)
    {
        if (!assembly) return false;
        //profile adaptor
        FITKAbaqusHDF5AdaptorAssembly* adaptor = FITKIOADAPTORFACTORY->createT<FITKAbaqusHDF5AdaptorAssembly>("HDF5", "Interface::FITKAbaAssembly");
        if (adaptor == nullptr)
        {
            return false;
        }
        adaptor->setDataObject(assembly);
        adaptor->setFileWriter(_writer);
        adaptor->setH5GroupData(h5Group);
        bool isW = adaptor->adaptW();
        delete adaptor;

        if (isW) _writer->consoleMessage(1, QString("Writer Assembly OK, Name : %1").arg(assembly->getDataObjectName()));
        else _writer->consoleMessage(3, QString("Writer Assembly Error, Name : %1").arg(assembly->getDataObjectName()));
        return isW;
    }

    bool FITKAbaqusHDF5AdaptorCase::writeStep(Interface::FITKAbaAbstractStep* step, H5::Group& h5Group)
    {
        if (!step) return false;
        //Step adaptor
        FITKAbaqusHDF5AdaptorStep* adaptor = FITKIOADAPTORFACTORY->createT<FITKAbaqusHDF5AdaptorStep>("HDF5", "Interface::FITKAbaAbstractStep");
        if (adaptor == nullptr)
        {
            return false;
        }
        adaptor->setDataObject(step);
        adaptor->setFileWriter(_writer);
        adaptor->setH5GroupData(h5Group);
        bool isW = adaptor->adaptW();
        delete adaptor;
        if (isW) _writer->consoleMessage(1, QString("Writer Step OK, Name : %1").arg(step->getDataObjectName()));
        else _writer->consoleMessage(3, QString("Writer Step Error, Name : %1").arg(step->getDataObjectName()));
        return isW;
    }

    bool FITKAbaqusHDF5AdaptorCase::writeOutput(Interface::FITKAbaAbstractOutput* output, H5::Group& h5Group)
    {
        if (!output || !_caseData) return false;
        bool isW = true;
        //Output adaptor
        FITKAbaqusHDF5AdaptorOutput* adaptor = FITKIOADAPTORFACTORY->createT<FITKAbaqusHDF5AdaptorOutput>("HDF5", "Interface::FITKAbaAbstractOutput");
        if (adaptor == nullptr)
        {
            return false;
        }
        adaptor->setDataObject(output);
        adaptor->setStepManager(_caseData->getStepManager());
        adaptor->setFileWriter(_writer);
        adaptor->setH5GroupData(h5Group);
        isW &= adaptor->adaptW();
        delete adaptor;
        if (isW) _writer->consoleMessage(1, QString("Writer Output OK, Name : %1").arg(output->getDataObjectName()));
        else _writer->consoleMessage(3, QString("Writer Output Error, Name : %1").arg(output->getDataObjectName()));
        return isW;
    }

    bool FITKAbaqusHDF5AdaptorCase::writeLoad(Interface::FITKAbstractLoad* load, H5::Group& h5Group)
    {
        if (!load || !_caseData) return false;
        //Load adaptor
        auto adaptor = FITKIOADAPTORFACTORY->createT<FITKAbaqusHDF5AdaptorLoad>("HDF5", "Interface::FITKAbaAbstractLoad");
        if (adaptor == nullptr)
        {
            return false;
        }
        adaptor->setDataObject(load);
        adaptor->setDataCase(_caseData);
        adaptor->setFileWriter(_writer);
        adaptor->setH5GroupData(h5Group);
        bool isW = adaptor->adaptW();
        delete adaptor;
        if (isW) _writer->consoleMessage(1, QString("Writer Load OK, Name : %1").arg(load->getDataObjectName()));
        else _writer->consoleMessage(3, QString("Writer Load Error, Name : %1").arg(load->getDataObjectName()));
        return isW;
    }

    bool FITKAbaqusHDF5AdaptorCase::writeAmplitude(Interface::FITKAbaAbstractAmplitude* amplitude, H5::Group& h5Group)
    {
        if (!amplitude) return false;
        //Amplitude adaptor
        auto adaptor = FITKIOADAPTORFACTORY->createT<FITKAbaqusHDF5AdaptorAmplitude>("HDF5", "Interface::FITKAbstractAmplitude");
        if (adaptor == nullptr)
        {
            return false;
        }
        adaptor->setDataObject(amplitude);
        adaptor->setFileWriter(_writer);
        adaptor->setH5GroupData(h5Group);
        bool isW = adaptor->adaptW();
        delete adaptor;
        if (isW) _writer->consoleMessage(1, QString("Writer Amplitude OK, Name : %1").arg(amplitude->getDataObjectName()));
        else _writer->consoleMessage(3, QString("Writer Amplitude Error, Name : %1").arg(amplitude->getDataObjectName()));
        return isW;
    }

    bool FITKAbaqusHDF5AdaptorCase::writeInteraction(Interface::FITKAbaAbstractInteraction* interaction, H5::Group& h5Group)
    {
        if (!interaction) return false;
        //Interaction adaptor
        auto adaptor = FITKIOADAPTORFACTORY->createT<FITKAbaqusHDF5AdaptorInteraction>("HDF5", "Interface::FITKAbaAbstractInteraction");
        if (adaptor == nullptr)
        {
            return false;
        }
        adaptor->setDataCase(_caseData);
        adaptor->setDataObject(interaction);
        adaptor->setFileWriter(_writer);
        adaptor->setH5GroupData(h5Group);
        bool isW = adaptor->adaptW();
        delete adaptor;
        if (isW) _writer->consoleMessage(1, QString("Writer Interaction OK, Name : %1").arg(interaction->getDataObjectName()));
        else _writer->consoleMessage(3, QString("Writer Interaction Error, Name : %1").arg(interaction->getDataObjectName()));
        return isW;
    }

    bool FITKAbaqusHDF5AdaptorCase::writeInteractionProperty(Interface::FITKAbaAbstractInteractionProperty* interactionProperty, H5::Group& h5Group)
    {
        if (!interactionProperty) return false;
        //InteractionProperty adaptor
        auto adaptor = FITKIOADAPTORFACTORY->createT<FITKAbaqusHDF5AdaptorInteractionProperty>("HDF5", "Interface::FITKAbaAbstractInteractionProperty");
        if (adaptor == nullptr)
        {
            return false;
        }
        adaptor->setDataObject(interactionProperty);
        adaptor->setFileWriter(_writer);
        adaptor->setH5GroupData(h5Group);
        bool isW = adaptor->adaptW();
        delete adaptor;
        if (isW) _writer->consoleMessage(1, QString("Writer InteractionProperty OK, Name : %1").arg(interactionProperty->getDataObjectName()));
        else _writer->consoleMessage(3, QString("Writer InteractionProperty Error, Name : %1").arg(interactionProperty->getDataObjectName()));
        return isW;
    }

    bool FITKAbaqusHDF5AdaptorCase::writeBoundary(Interface::FITKAbstractBC* BoundaryCondition, H5::Group& h5Group)
    {
        if (!BoundaryCondition) return false;
        //Boundary adaptor
        auto adaptor = FITKIOADAPTORFACTORY->createT<FITKAbaqusHDF5AdaptorBoundary>("HDF5", "Interface::FITKAbaAbstractBoundaryCondition");
        if (adaptor == nullptr)
        {
            return false;
        }
        adaptor->setDataCase(_caseData);
        adaptor->setDataObject(BoundaryCondition);
        adaptor->setFileWriter(_writer);
        adaptor->setH5GroupData(h5Group);
        bool isW = adaptor->adaptW();
        delete adaptor;
        if (isW) _writer->consoleMessage(1, QString("Writer BoundaryCondition OK, Name : %1").arg(BoundaryCondition->getDataObjectName()));
        else _writer->consoleMessage(3, QString("Writer BoundaryCondition Error, Name : %1").arg(BoundaryCondition->getDataObjectName()));
        return isW;
    }

    bool FITKAbaqusHDF5AdaptorCase::writeConstraint(Interface::FITKAbaAbstractConstraint* constraint, H5::Group& h5Group)
    {
        if (!constraint) return false;
        //Constraint adaptor
        auto adaptor = FITKIOADAPTORFACTORY->createT<FITKAbaqusHDF5AdaptorConstraint>("HDF5", "Interface::FITKAbaAbstractConstraint");
        if (adaptor == nullptr)
        {
            return false;
        }
        adaptor->setDataObject(constraint);
        adaptor->setFileWriter(_writer);
        adaptor->setH5GroupData(h5Group);
        bool isW = adaptor->adaptW();
        delete adaptor;
        if (isW) _writer->consoleMessage(1, QString("Writer Constraint OK, Name : %1").arg(constraint->getDataObjectName()));
        else _writer->consoleMessage(3, QString("Writer Constraint Error, Name : %1").arg(constraint->getDataObjectName()));
        return isW;
    }

    bool FITKAbaqusHDF5AdaptorCase::writeTimePoints(Interface::FITKAbaTimePoints* timepoints, H5::Group& h5Group)
    {
        if (!timepoints) return false;
        //TimePoints adaptor
        auto adaptor = FITKIOADAPTORFACTORY->createT<FITKAbaqusHDF5AdaptorTimePoints>("HDF5", "Interface::FITKAbaTimePoints");
        if (adaptor == nullptr)
        {
            return false;
        }
        adaptor->setDataObject(timepoints);
        adaptor->setFileWriter(_writer);
        adaptor->setH5GroupData(h5Group);
        bool isW = adaptor->adaptW();
        delete adaptor;
        if (isW) _writer->consoleMessage(1, QString("Writer TimePoints OK, Name : %1").arg(timepoints->getDataObjectName()));
        else _writer->consoleMessage(3, QString("Writer TimePoints Error, Name : %1").arg(timepoints->getDataObjectName()));
        return isW;
    }

    bool FITKAbaqusHDF5AdaptorCase::writeConnectorSection(Interface::FITKAbaConnectorSection* connectorSection, H5::Group& h5Group)
    {
        if (!connectorSection) return false;
        auto adaptor = FITKIOADAPTORFACTORY->createT<FITKAbaqusHDF5AdaptorConnectorSection>("HDF5", connectorSection);
        if (adaptor == nullptr) return false;
        adaptor->setDataObject(connectorSection);
        adaptor->setFileWriter(_writer);
        adaptor->setH5GroupData(h5Group);
        bool isW = adaptor->adaptW();
        delete adaptor;
        if (isW) _writer->consoleMessage(1, QString("Writer ConnectorSection OK, Name : %1").arg(connectorSection->getDataObjectName()));
        else _writer->consoleMessage(3, QString("Writer ConnectorSection Error, Name : %1").arg(connectorSection->getDataObjectName()));
        return isW;
    }
}
